<div class="page_header_groups">
<?php echo '<p class=p_header>' . $header_title . '</p>';?>
</div>
<div id="bulletin_container">
    <!--<p>Filters</p>-->
    <div style="min-height: 150px;border: black solid thin;display: none;background: white;border-radius: 5px;">
        <?php
//        $month_list = ['JANUARY', 'FEBRUARY', 'MARCH', 'APRIL', 'MAY',
//                    'JUNE', 'JULY', 'AUGUST', 'SEPTEMBER', 'OCTOBER', 'NOVEMBER', 
//                    'DECEMBER'];
//                $month_href = ['authenticated/bulletin/filter_by_month/january','authenticated/bulletin/filter_by_month/february',
//                    site_url().'authenticated/bulletin/filter_by_month/march', 'authenticated/bulletin/filter_by_month/april', 
//                    site_url().'authenticated/bulletin/filter_by_month/may', 'authenticated/bulletin/filter_by_month/june', 
//                    site_url().'authenticated/bulletin/filter_by_month/july', 'authenticated/bulletin/filter_by_month/august', 
//                    site_url().'authenticated/bulletin/filter_by_month/september', 'authenticated/bulletin/filter_by_month/october', 
//                    site_url().'authenticated/bulletin/filter_by_month/november', 'authenticated/bulletin/filter_by_month/december'];
//                $month_group_href = [
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/january',
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/february',
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/march',
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/april', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/may', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/june', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/july', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/august', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/september', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/october', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/november', 
//                    site_url().'authenticated/group_post/'.$this->uri->segment(3).'/filter_by_month/december'];
//                foreach($years as $bulletin_item) {
//                         if($segment === 'bulletin') {
//                        for($i = 0; $i<sizeof($month_list); $i++){
//                            echo anchor($month_href[$i].'/'.$bulletin_item['years'], $month_list[$i], 'class="months"');
//                        }
//                    } else {
//                        for($i = 0; $i<sizeof($month_list); $i++){
//                            echo anchor($month_group_href[$i].'/'.$bulletin_item['years'], $month_list[$i], 'class="months"');
//                        }
//                    }
//                }
//        
//         foreach($group_info as $group) {
//                echo '<p class="sub_group_name"><a href="'.site_url().'authenticated/group_post/'.$group['group_id'].'">'.$group['group_name'].'</a></p>';
//            } 
                ?>
    </div>
    <div id="bulletin_sidebar">
        <div id="notification_post">
            <p class="menu_title">Menu</p>
            <?php
            echo '<p class="sub_group_name">'.anchor(site_url().'authenticated/posts','All').'</p>';
                echo '<p class="sub_group_name">'.anchor(site_url().'authenticated/bulletin/posts', 'Bulletin Posts').'</p>';
                echo '<p class="sub_group_name">'.anchor(site_url().'authenticated/group/posts', 'Group Posts').'</p>';
             
            ?>
        </div>
        <div id="year_filter">
            <p class="menu_title">Filter by year</p>
            <?php 
                foreach($years as $bulletin_item) {
                    if($this->uri->segment(2) === 'posts' || $this->uri->segment(2) === 'index') {
                        echo '<div class="filter_year"><p class="year" id="filter_year_'.$bulletin_item['years'].'"><a href="'.site_url().
                                'authenticated/filter_by_year/'.$bulletin_item['years'].'/index">'.$bulletin_item['years'].
                                '</a></p></div>';
                    }else if($this->uri->segment(1) === 'authenticated_page_c') {
                        echo '<div class="filter_year"><p class="year" id="filter_year_'.$bulletin_item['years'].'"><a href="'.site_url().
                                'authenticated/filter_by_year/'.$bulletin_item['years'].'/authen">'.$bulletin_item['years'].
                                '</a></p></div>';
                    } else if($this->uri->segment(2) === 'group' && $this->uri->segment(3) === 'posts' || $this->uri->segment(2) === 'all_bulletin_post') {
                        echo '<div class="filter_year"><p class="year" id="filter_year_'.$bulletin_item['years'].'"><a href="'.site_url().
                                'authenticated/filter_by_year/'.$bulletin_item['years'].'/group">'.$bulletin_item['years'].
                                '</a></p></div>';
                    } else if($this->uri->segment(2) === 'bulletin' && $this->uri->segment(3) === 'posts') {
                        echo '<div class="filter_year"><p class="year" id="filter_year_'.$bulletin_item['years'].'"><a href="'.site_url().
                                'authenticated/filter_by_year/'.$bulletin_item['years'].'/bulletin">'.$bulletin_item['years'].
                                '</a></p></div>';
                    } else if($this->uri->segment(2) === 'filter_by_year') {
                        echo '<div class="filter_year"><p class="year" id="filter_year_'.$bulletin_item['years'].'"><a href="'.site_url().
                                'authenticated/filter_by_year/'.$bulletin_item['years'].'/index">'.$bulletin_item['years'].
                                '</a></p></div>';
                    }
                }
            ?>
        </div>
    </div>
    <div id="bulletin_post">
        <?php
        foreach($bulletin as $bulletin_item): ?> 
        <div class="post">
            
                <div class="date_pub">
                    <p class="pub_day"><?php echo $bulletin_item->day; ?></p>
                    <p class="pub_month"><?php echo $bulletin_item->month; ?></p>
                    <p class="pub_year"><?php echo $bulletin_item->year; ?></p>
                </div>
                <div class="post_content">
                    <?php echo '<div class="post_title_author_wrapper" id="post_title_author_'.$bulletin_item->post_id.'">'; ?>
                        <?php 
                        if($this->uri->segment(2) === 'posts'){
                            echo "<a href='".site_url()."authenticated/posts/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }else if($this->uri->segment(2) === 'index'){
                            echo "<a href='".site_url()."authenticated/posts/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }else if($this->uri->segment(2) === 'bulletin'){
                            echo "<a href='".site_url()."authenticated/bulletin/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }else if($this->uri->segment(2) === 'all_bulletin_post'){
                            echo "<a href='".site_url()."authenticated/bulletin/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }else if($this->uri->segment(2) === 'group'){
                            echo "<a href='".site_url()."authenticated/group_post/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }else if($this->uri->segment(2) === 'all_group_post'){
                            echo "<a href='".site_url()."authenticated/group_post/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }else if($this->uri->segment(2) === 'filter_by_year'){
                            echo "<a href='".site_url()."authenticated/posts/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }else if($this->uri->segment(2) === 'filter_bulletin_post_by_year'){
                            echo "<a href='".site_url()."authenticated/posts/read_full_story/".$bulletin_item->post_id."' class='post_title'>$bulletin_item->title</a>";
                        }
                        ?>
                    </div>

                    <?php echo '<div class="post_summary_wrapper" id="post_summary_'.$bulletin_item->post_id.'">'; ?>
                        <?php echo $bulletin_item->summary; 
//                         if($this->uri->segment(2) === 'bulletin'){ 
//                        echo '<a href="'.site_url().'authenticated/bulletin/read_full_story/'. $bulletin_item->post_id.'" class="read_more">Read Full Story</a>'; 
//                         } else{ 
//                        echo '<a href="'.site_url().'authenticated/group_post/read_full_story/'. $bulletin_item->post_id.'" class="read_more">Read Full Story</a>'; 
//                        } ?>
                        <div class="balancer"></div>
                    </div>
                    <?php
                        if($this->uri->segment(2) !== 'bulletin'){
                          echo '<p class="location"><span>Location:</span>'.$bulletin_item->lokasyon.'</p>';    
                        }
                    ?>
                </div>
                <hr/>
                <div class="balancer"></div>
            </div>
        <?php endforeach; ?>
        <p><?php echo $links; ?></p>
    <?php echo '</div>'; ?>
        <div class="balancer"></div>
</div>


<script>
  var tiles1 = document.getElementsByClassName('date_pub');
  
  for(var i = 0; i < tiles1.length; i++) {
      var tile = tiles1[i];
      var color = get_random_color();
      tile.style.background = get_random_color();
  }

function get_random_color() {
    var letters = '678abcd'.split('');
    var color = '#';
    for (var i = 0; i < 6; i++ ) {
        color += letters[Math.round(Math.random() * 6)];
    }
    return color;
}


</script>
